
//- This Source Code Form is subject to the terms of the Mozilla Public
//- License, v. 2.0. If a copy of the MPL was not distributed with this
//- file, You can obtain one at http://mozilla.org/MPL/2.0/.
//-
//- Copyright (c) 2021-present Kaleidos Ventures SL

header(tg-backlog-sprint-header)

.summary-progress-wrapper
    .sprint-progress-bar(tg-progress-bar="100 * sprint.closed_points / sprint.total_points")

div.sprint-table(tg-bind-scope, ng-class="{'sprint-empty-wrapper': !sprint.user_stories.length}")
    div.sprint-empty(ng-if="!sprint.user_stories.length")
        span(tg-class-permission="{'hidden': 'modify_us'}") {{ 'BACKLOG.SPRINTS.WARNING_EMPTY_SPRINT_ANONYMOUS' | translate }}
        span(tg-class-permission="{'hidden': '!modify_us'}") {{ 'BACKLOG.SPRINTS.WARNING_EMPTY_SPRINT' | translate }}
    div.row.milestone-us-item-row(
        ng-repeat="us in sprint.user_stories track by us.id"
        tg-bind-scope
        data-id="{{ us.id }}"
        tg-class-permission="{'readonly': '!modify_us'}"
        ng-class="{closedRow: us.is_closed, blockedRow: us.is_blocked}"
    )
        div.column-us
            a.us-name.clickable(tg-nav="project-userstories-detail:project=project.slug,ref=us.ref",
                ng-if="us.milestone"
                tg-nav-get-params="{\"milestone\": {{us.milestone}}}"
                tg-bo-title="'#' + us.ref + ' ' +  us.subject",
                ng-class="{closed: us.is_closed, blocked: us.is_blocked}"
            )
                span.us-ref-text(
                    tg-bo-ref="us.ref"
                )
                span.us-name-text(
                    tg-bind-html="us.subject | emojify"
                )
                tg-belong-to-epics(
                    class="us-epic-container"
                    format="pill"
                    ng-if="us.epics"
                    epics="us.epics"
                )
                tg-due-date.due-date(
                    due-date="us.due_date"
                    is-closed="us.is_closed"
                    ng-if="us.due_date"
                    obj-type="us"
                )
        div.column-points.width-1(
            ng-if="us.total_points"
            ng-class="{closed: us.is_closed, blocked: us.is_blocked}"
        )
            span.points-container(tg-bo-bind="us.total_points")

a.btn-small(
    title="{{ 'BACKLOG.SPRINTS.TITLE_LINK_TASKBOARD' | translate: {\"name\": sprint.name} }}",
    tg-nav="project-taskboard:project=project.slug,sprint=sprint.slug",
    tg-check-permission="view_milestones",
    variant="secondary"
    )

    span(translate="BACKLOG.SPRINTS.LINK_TASKBOARD")
